<?php

class Menu extends MX_Controller {
	function Menu()
	{
		parent::__construct();	
	}
	
	function index()
	{	
		
		
		$this->load->model('menu_model');
		$this->load->model('public_model');
		$this->load->library('CommonUtils');
		// get main template with URL
		$webstoreObj=$this->public_model->getTemplateForUrl();
		$webstore="";
		$mainmenu="";
		if(count($webstoreObj)==0){
   			//get template of givemart in system parameters
   			$menuType="mainmenu";
   			$webstore="";
   		}else{
   			$menuType="webstore";
   			$webstore=$webstoreObj['webstore'];
   		}
		$menu['items'] = $this->menu_model->getMenu($menuType,$webstore);
		$parentmenu=array();
		$submenu=array();
		foreach($menu['items'] as $item){
			if($item->pr==0){
				array_push($parentmenu,$item);
			}else{
				array_push($submenu,$item);
			}
			
		}
			
		$menu['parentmenu']=$parentmenu;
		$menu['submenu']=$submenu;
		$this->load->view('menu', $menu);
	}
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */